var __extends =
    (this && this.__extends) ||
    (function () {
      var i = function (t, e) {
        return (i =
          Object.setPrototypeOf ||
          ({ __proto__: [] } instanceof Array &&
            function (i, t) {
              i.__proto__ = t;
            }) ||
          function (i, t) {
            for (var e in t)
              Object.prototype.hasOwnProperty.call(t, e) && (i[e] = t[e]);
          })(t, e);
      };
      return function (t, e) {
        function n() {
          this.constructor = t;
        }
        if ("function" != typeof e && null !== e)
          throw new TypeError(
            "Class extends value " + String(e) + " is not a constructor or null"
          );
        i(t, e),
          (t.prototype =
            null === e
              ? Object.create(e)
              : ((n.prototype = e.prototype), new n()));
      };
    })(),
  FingerGuessingGameView = (function (i) {
    function t() {
      var t = i.call(this) || this;
      return (
        (t.chipNum = 0),
        (t.chipCarryNum = 0),
        (t.chipNumMax = 0),
        (t.curChipNum = 0),
        (t.fingure_type = "-1"),
        t.btn_finguer_back.on(
          Laya.Event.CLICK,
          t,
          t.onFingerGuessBackPreAction
        ),
        t.btn_finguess_gzsm.on(Laya.Event.CLICK, t, t.OnDidClickGZSMAction),
        t.btn_finguess_jlsm.on(Laya.Event.CLICK, t, t.OnDidClickJLSMAction),
        WebSocketService.addListener({
          caller: t,
          code: 1700,
          method: t.onLoadXiaoQuanQuanViewData,
        }),
        WebSocketService.addListener({
          caller: t,
          code: 1701,
          method: t.onLoadXiaoQuanQuanListSeqData,
        }),
        WebSocketService.addListener({
          caller: t,
          code: 1703,
          method: t.onLoadXQQFightListData,
        }),
        WebSocketService.addListener({
          caller: t,
          code: 1709,
          method: t.onLoadOtherStartFightData,
        }),
        WebSocketService.addListener({
          caller: t,
          code: 1707,
          method: t.onLoadMyStartFightData,
        }),
        (t.list_fingerguess.vScrollBarSkin = ""),
        (t.list_fingerguess.selectEnable = !0),
        (t.list_fingerguess.renderHandler = new Handler(
          t,
          t.onupdateFingerGuessItemFn
        )),
        (t.list_fingure_fight.vScrollBarSkin = ""),
        (t.list_fingure_fight.selectEnable = !0),
        t.list_fingure_fight.on(Laya.Event.CLICK, t, t.onFingureFightDidClick),
        t.btn_fin_fight_cancle.on(Laya.Event.CLICK, t, t.onFightCancleAction),
        t.btn_fin_fight_sure.on(Laya.Event.CLICK, t, t.onFightSureAction),
        t.btn_fin_dele.on(Laya.Event.CLICK, t, t.onSelectedChipAction),
        t.btn_fin_add.on(Laya.Event.CLICK, t, t.onSelectedChipAction),
        t.btn_fin_shitou.on(Laya.Event.CLICK, t, t.onLoadFingureThingAction),
        t.btn_fin_jiandao.on(Laya.Event.CLICK, t, t.onLoadFingureThingAction),
        t.btn_fin_bu.on(Laya.Event.CLICK, t, t.onLoadFingureThingAction),
        t.btn_fingure_startfight.on(
          Laya.Event.CLICK,
          t,
          t.onMySelfStartFightAction
        ),
        t.btn_fingure_refresh.on(Laya.Event.CLICK, t, t.onFingureRefreshAction),
        t
      );
    }
    return (
      __extends(t, i),
      (t.showFingerGuessView = function () {
        return (
          null == this.fingerGuessV && (this.fingerGuessV = new t()),
          WebSocketService.send({ c: 1700, d: { c: 0 } }),
          WebSocketService.send({ c: 1701, d: { c: 0, pageNum: 0 } }),
          this.fingerGuessV.dealShowCurrentFightLevelView("1"),
          (this.fingerGuessV.list_fingerguess.visible = !1),
          (this.fingerGuessV.list_fingure_fight.visible = !1),
          (this.fingerGuessV.btn_fin_shitou.selected = !1),
          (this.fingerGuessV.btn_fin_jiandao.selected = !1),
          (this.fingerGuessV.btn_fin_bu.selected = !1),
          this.fingerGuessV
        );
      }),
      (t.prototype.onLoadXiaoQuanQuanViewData = function (i) {
        0 == i.code
          ? ("1" == i.data.s
              ? ((this.isStartXQQState = !0),
                (this.label_xqq_paiming.text = ""),
                this.dealCurrentViewIsStarting(!0),
                (this.label_xiaoquanquan_timeDown.align = "left"),
                (this.label_xqq_paiming.text =
                  "您当前处于 " + i.data.i + " 名"),
                (this.chipCarryNum = i.data.m),
                (this.chipNumMax = i.data.max),
                (this.curChipNum = 500),
                this.curChipNum == this.chipNumMax &&
                  this.chipNumMax <= 500 &&
                  (this.btn_fin_dele.visible = !1),
                this.curChipNum > this.chipNumMax &&
                  (this.btn_fin_add.visible = !1),
                (this.label_fight_chouma.text = this.curChipNum + ""))
              : ((this.isStartXQQState = !1),
                this.dealCurrentViewIsStarting(!1),
                (this.label_xiaoquanquan_timeDown.align = "center")),
            (this.hdId = i.data.id),
            WebSocketService.send({ c: 1703, d: { id: this.hdId } }),
            (this.label_current_seq.text =
              "您现有" +
              i.data.m +
              "筹码，" +
              i.data.w +
              "胜" +
              i.data.l +
              "负，排名第" +
              i.data.i),
            (this.timeDiff = i.data.t),
            Laya.timer.loop(1e3, this, this.timerCountDownMatchFn))
          : (ToastView.toastView(i.msg),
            (this.label_fingure_shangjiesaikuang.visible = !1),
            (this.btn_fingure_startfight.visible = !1));
      }),
      (t.prototype.onLoadXQQFightListData = function (i) {
        if (0 == i.code) {
          var t = void 0;
          this.isStartXQQState
            ? this.dealShowCurrentFightLevelView("1")
            : (this.list_fingure_fight.visible = !1);
          var e = [];
          (this.fightArr = []), (this.fightArr = i.list);
          for (var n = 0; n < this.fightArr.length; n++) {
            var s = this.fightArr[n];
            (t = {
              label_fight_username: {
                text: "玩家" + this.dealFightOtherName(n),
              },
              label_fight_carrything: { text: s.wi + "胜" + s.l + "负" },
              label_fight_chouma: { text: "（ 赌注" + s.w + " )" },
              btn_fight_jieshou: { label: "挑战" },
            }),
              e.push(t);
          }
          this.list_fingure_fight.dataSource = e;
        }
      }),
      (t.prototype.dealCurrentViewIsStarting = function (i) {
        i
          ? ((this.list_fingerguess.y = 400),
            (this.label_xqq_paiming.visible = !1),
            (this.label_fingure_shangjiesaikuang.visible = !1),
            (this.label_current_seq.visible = !0),
            (this.btn_fingure_refresh.visible = !0),
            (this.image_fingure_faqi_bg.visible = !0),
            (this.label_fingure_curPaihang.visible = !0),
            (this.btn_fingure_startfight.visible = !0))
          : ((this.list_fingerguess.y = 232),
            (this.label_xqq_paiming.visible = !0),
            (this.label_fingure_shangjiesaikuang.visible = !0),
            (this.label_current_seq.visible = !1),
            (this.btn_fingure_refresh.visible = !1),
            (this.image_fingure_faqi_bg.visible = !1),
            (this.label_fingure_curPaihang.visible = !1),
            (this.btn_fingure_startfight.visible = !1));
      }),
      (t.prototype.dealShowCurrentFightLevelView = function (i) {
        (this.fingure_type = "-1"),
          (this.btn_fin_shitou.selected = !1),
          (this.btn_fin_jiandao.selected = !1),
          (this.btn_fin_bu.selected = !1),
          "1" == i
            ? ((this.list_fingure_fight.visible = !0),
              (this.label_fin_shuruchouma.visible = !1),
              (this.label_fin_tips.visible = !1),
              (this.btn_fin_dele.visible = !1),
              (this.btn_fin_add.visible = !1),
              (this.label_fight_chouma.visible = !1),
              (this.label_fin_qingchuquan.visible = !1),
              (this.btn_fin_shitou.visible = !1),
              (this.btn_fin_jiandao.visible = !1),
              (this.btn_fin_bu.visible = !1),
              (this.btn_fin_fight_cancle.visible = !1),
              (this.btn_fin_fight_sure.visible = !1))
            : "2" == i
            ? ((this.isWhoStart = "myStart"),
              (this.list_fingure_fight.visible = !1),
              (this.label_fin_shuruchouma.visible = !0),
              (this.label_fin_tips.visible = !0),
              (this.btn_fin_dele.visible = !0),
              (this.btn_fin_add.visible = !0),
              (this.label_fight_chouma.visible = !0),
              (this.label_fin_qingchuquan.y = 67),
              (this.label_fin_qingchuquan.text = "请出拳："),
              (this.btn_fin_shitou.y = 89),
              (this.btn_fin_jiandao.y = 89),
              (this.btn_fin_bu.y = 87),
              (this.label_fin_qingchuquan.visible = !0),
              (this.btn_fin_shitou.visible = !0),
              (this.btn_fin_jiandao.visible = !0),
              (this.btn_fin_bu.visible = !0),
              (this.btn_fin_fight_cancle.visible = !0),
              (this.btn_fin_fight_sure.visible = !0),
              this.curChipNum >= this.chipNumMax
                ? (this.btn_fin_add.visible = !1)
                : (this.btn_fin_add.visible = !0),
              this.curChipNum <= 500
                ? (this.btn_fin_dele.visible = !1)
                : (this.btn_fin_dele.visible = !0))
            : "3" == i &&
              ((this.isWhoStart = "otherStart"),
              (this.list_fingure_fight.visible = !1),
              (this.label_fin_shuruchouma.visible = !1),
              (this.label_fin_tips.visible = !1),
              (this.btn_fin_dele.visible = !1),
              (this.btn_fin_add.visible = !1),
              (this.label_fight_chouma.visible = !1),
              (this.label_fin_qingchuquan.y = 20),
              (this.label_fin_qingchuquan.text =
                "对方投入" + this.otherChipNum + "筹码"),
              (this.btn_fin_shitou.y = 60),
              (this.btn_fin_jiandao.y = 60),
              (this.btn_fin_bu.y = 60),
              (this.label_fin_qingchuquan.visible = !0),
              (this.btn_fin_shitou.visible = !0),
              (this.btn_fin_jiandao.visible = !0),
              (this.btn_fin_bu.visible = !0),
              (this.btn_fin_fight_cancle.visible = !0),
              (this.btn_fin_fight_sure.visible = !0),
              this.curChipNum > this.chipNumMax &&
                (this.btn_fin_add.visible = !1));
      }),
      (t.prototype.onLoadXiaoQuanQuanListSeqData = function (i) {
        if (0 == i.code) {
          this.matchArray = [];
          var t = void 0;
          if (this.currentPage >= 1) {
            if (0 == i.list.length) return void this.currentPage--;
            for (var e = 0; e < i.list.length; e++) {
              var n = i.list[e];
              this.matchArray.push(n), (this.dataSource = []);
            }
          } else (this.matchArray = i.list), (this.dataSource = []);
          (this.isloading = !1), (this.list_fingerguess.visible = !0);
          for (var s = 0; s < this.matchArray.length; s++) {
            var a = this.matchArray[s];
            (t = {
              label_fingure_index: { text: this.dealFingureIndex(a.i) },
              label_match_name: {
                text: a.n + " (" + a.m + "筹码,胜" + a.w + " )",
              },
            }),
              this.dataSource.push(t);
          }
          this.list_fingerguess.dataSource = this.dataSource;
        }
      }),
      (t.prototype.dealFingureIndex = function (i) {
        return "1" == i ? "冠军" : "2" == i ? "亚军" : "3" == i ? "季军" : i;
      }),
      (t.prototype.timerCountDownMatchFn = function () {
        this.timeDiff--;
        var i = 0,
          t = 0,
          e = 0,
          n = 0;
        (i = Math.floor(this.timeDiff / 86400)),
          (t = Math.floor((this.timeDiff % 86400) / 3600)),
          (e = Math.floor((this.timeDiff % 3600) / 60)),
          (n = Math.floor(this.timeDiff % 60)),
          i <= 0 && t <= 0 && e <= 0 && n <= 1
            ? (Laya.timer.clear(this, this.timerCountDownMatchFn),
              (this.label_xiaoquanquan_timeDown.text = "请稍等..."))
            : (this.label_xiaoquanquan_timeDown.text =
                this.dealTimeDataWithParams(i, t, e, n));
      }),
      (t.prototype.dealTimeDataWithParams = function (i, t, e, n) {
        var s = "0秒";
        i > 0
          ? (s = i + "天" + t + "小时" + e + "分" + n + "秒")
          : t > 0
          ? (s = t + "小时" + e + "分" + n + "秒")
          : e > 0
          ? (s = e + "分" + n + "秒")
          : n > 0 && (s = n + "秒");
        return this.isStartXQQState ? s + "后结束比赛" : "距离比赛开始还有" + s;
      }),
      (t.prototype.onupdateFingerGuessItemFn = function (i, t) {
        if (!(t > this.matchArray.length)) {
          var e = i.getChildByName("label_fingure_index");
          e.color =
            0 == t
              ? "#FFFF00"
              : 1 == t
              ? "#c0c0c0"
              : 2 == t
              ? "#CDAF95"
              : "#FFFFFF";
        }
      }),
      (t.prototype.onFingureFightDidClick = function (i) {
        if ("" != i.target.name && "btn_fight_jieshou" == i.target.name) {
          var t = this.fightArr[this.list_fingure_fight.selectedIndex];
          (this.otherChipNum = t.w),
            (this.other_lid = t.lid),
            this.dealShowCurrentFightLevelView("3");
        }
      }),
      (t.prototype.OnDidClickGZSMAction = function () {
        var i = RulesView.showCaslRuleView("xiaoquanquanGZSM");
        (i.y = 0), Laya.stage.addChild(i);
      }),
      (t.prototype.OnDidClickJLSMAction = function () {
        var i = RulesView.showCaslRuleView("xiaoquanquanJLSM");
        (i.y = 0), Laya.stage.addChild(i);
      }),
      (t.prototype.onFightCancleAction = function () {
        this.dealShowCurrentFightLevelView("1");
      }),
      (t.prototype.onFightSureAction = function () {
        if (parseInt(this.hdId) <= 0) ToastView.toastView("活动有误");
        else if (parseInt(this.fingure_type) <= 0)
          ToastView.toastView("请先选择出拳类型");
        else if ("otherStart" == this.isWhoStart)
          WebSocketService.send({
            c: 1709,
            d: { id: this.hdId, lid: this.other_lid, t: this.fingure_type },
          });
        else if ("myStart" == this.isWhoStart) {
          if (this.curChipNum <= 0)
            return void ToastView.toastView("请先出下注筹码");
          WebSocketService.send({
            c: 1707,
            d: { id: this.hdId, w: this.curChipNum, t: this.fingure_type },
          }),
            this.dealShowCurrentFightLevelView("1");
        }
      }),
      (t.prototype.onSelectedChipAction = function (i) {
        "item_fin_dele" == i.target.name
          ? ((this.btn_fin_add.visible = !0),
            this.curChipNum <= 500
              ? (this.curChipNum = 500)
              : (this.curChipNum -= 500))
          : "item_fin_add" == i.target.name &&
            (this.curChipNum >= this.chipNumMax
              ? ((this.curChipNum = this.chipNumMax),
                (this.btn_fin_add.visible = !1))
              : (this.curChipNum += 500)),
          this.curChipNum >= this.chipNumMax
            ? (this.btn_fin_add.visible = !1)
            : (this.btn_fin_add.visible = !0),
          this.curChipNum <= 500
            ? (this.btn_fin_dele.visible = !1)
            : (this.btn_fin_dele.visible = !0),
          (this.label_fight_chouma.text = this.curChipNum + "");
      }),
      (t.prototype.onLoadFingureThingAction = function (i) {
        (this.btn_fin_shitou.selected = !1),
          (this.btn_fin_jiandao.selected = !1),
          (this.btn_fin_bu.selected = !1),
          "item_shitou" == i.target.name
            ? ((this.btn_fin_shitou.selected = !0), (this.fingure_type = "1"))
            : "item_jiandao" == i.target.name
            ? ((this.btn_fin_jiandao.selected = !0), (this.fingure_type = "2"))
            : "item_bu" == i.target.name &&
              ((this.btn_fin_bu.selected = !0), (this.fingure_type = "3"));
      }),
      (t.prototype.onFingureRefreshAction = function () {
        WebSocketService.send({ c: 1700, d: { c: 0 } }),
          WebSocketService.send({ c: 1701, d: { c: 0, pageNum: 0 } });
      }),
      (t.prototype.onMySelfStartFightAction = function () {
        (this.isWhoStart = "myStart"), this.dealShowCurrentFightLevelView("2");
      }),
      (t.prototype.onLoadMyStartFightData = function (i) {
        ToastView.toastView(i.msg),
          this.dealShowCurrentFightLevelView("1"),
          WebSocketService.send({ c: 1700, d: { c: 1 } });
      }),
      (t.prototype.onLoadOtherStartFightData = function (i) {
        var t = "";
        if (0 == i.code) {
          var e = i.data[0];
          "0" == e
            ? (t = t + "输了 失去" + i.data[1])
            : "1" == e
            ? (t = t + "胜利 获得" + i.data[1])
            : "2" == e && (t += "平了 "),
            ToastView.toastView(t),
            WebSocketService.send({ c: 1700, d: { c: 1 } }),
            WebSocketService.send({ c: 1701, d: { c: 1, pageNum: 0 } });
        } else ToastView.toastView(i.msg);
      }),
      (t.prototype.onLoadMoreData = function (i) {
        var t = i / this.list_fingerguess.scrollBar.max,
          e = new Date(),
          n = !1;
        if (
          (e.getTime() - this.spaceTime >= 3e3 && (n = !0),
          1 == t && 0 == this.isloading && n)
        )
          return (
            (this.isloading = !0),
            this.currentPage++,
            WebSocketService.send({
              c: 1701,
              d: { c: 0, pageNum: this.currentPage },
            }),
            void (this.spaceTime = e.getTime())
          );
      }),
      (t.prototype.dealFightOtherName = function (i) {
        return 0 == i
          ? "A"
          : 1 == i
          ? "B"
          : 2 == i
          ? "C"
          : 3 == i
          ? "D"
          : 4 == i
          ? "E"
          : 5 == i
          ? "F"
          : 6 == i
          ? "G"
          : void 0;
      }),
      (t.prototype.onFingerGuessBackPreAction = function () {
        Laya.timer.clear(this, this.timerCountDownMatchFn),
          Laya.timer.clearAll(this),
          this.removeSelf();
      }),
      t
    );
  })(ui.ChallengeBattle.FingerGuessingGameViewUI);
